package com.mall4j.cloud.base.exception;

/**
 * 异常工具类
 *
 * @author lihuan
 */
public class Asserts {

    private Asserts() {
    }

    public static void fail(String message) {
        throw new BaseException(message);
    }

    public static void fail(IErrorCode errorCode) {
        throw new BaseException(errorCode);
    }

    public static void fail(BaseException baseException) {
        throw baseException;
    }

    public static void check(final boolean expression, final String errMsg) {
        if (!expression) {
            throw new BaseException(errMsg);
        }
    }

    public static void check(final boolean expression, final String message, final Object... args) {
        if (!expression) {
            throw new BaseException(String.format(message, args));
        }
    }
}
